package admin

import "os"

type DownloadController struct {
	BaseController
}

func (c *DownloadController) Prepare() {
	c.EnableXSRF = false
}

func (c *DownloadController) Index() {
	name := c.Ctx.Input.Param(":name")
	if len(name) <= 0 {
		c.Ctx.WriteString("")
		return
	}
	path := "./static/" + name
	_, err := os.Stat(path)
	if err != nil {
		c.Ctx.WriteString("")
		return
	}
	c.Ctx.Output.Download(path)
}